﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.DAL
{
    /// <summary>
    /// PaperAnswer数据类
    /// </summary>
    public class PaperAnswer
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public PaperAnswer()
        { }

        /// <summary>
        /// 判断某个题目是否已存在答题
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-25</date>
        /// <param name="paperTopicId">题目编号</param>
        /// <returns>题目是否存在</returns>
        public bool ExistsByTopicID(decimal paperTopicId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from t_PaperAnswer");
            strSql.Append(" where FPaperTopicId=@FPaperTopicId");
            SqlParameter[] parameters = {
					new SqlParameter("@FPaperTopicId", SqlDbType.Decimal)
			};
            parameters[0].Value = paperTopicId;

            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 获取题目编号组中存在已有答题的题目编号
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-25</date>
        /// <param name="paperTopicIDs">题目编号</param>
        /// <returns>DataSet表</returns>
        public DataSet GetAnswerExistsByTopicIDS(string paperTopicIDs)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select FPaperTopicId from t_PaperAnswer");
            if (paperTopicIDs != string.Empty)
            {
                strSql.Append(" where FPaperTopicId in(");
                strSql.Append(paperTopicIDs);
                strSql.Append(")");
            }


            return DbHelperSQL.Query(strSql.ToString());
        }
       

    }
}
